
from django.urls import path, re_path
# from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from . import views

# 定义app_name可用于动态调用url path的name,
# 但是定义之后就不能单独使用url path的name获取url
app_name = "polls"

urlpatterns = [
    # path('', views.index),
    #
    # # 使用参数.格式1
    # path('bio/<username>', views.bio, name='bio'),
    # # 限制参数类型
    # path('num/<int:num>', views.num, name='num'),
    #
    # # 使用正则定义url参数
    # re_path('bio2/(?P<username>\w+)/$', views.bio2, name='bio2'),
    #
    # # 例： /polls/5/
    # path("<int:question_id>/", views.detail, name='detail'),
    # # 例： /polls/5/result/
    # path("<int:question_id>/results/", views.results, name='results'),

    path('', views.IndexView.as_view(), name='index'),
    path('<int:pk>', views.DetailView.as_view(), name='detail'),
    path('<int:pk>/results/', views.ResultsView.as_view(), name='results'),
    # 例: /polls/5/vote/
    path("<int:question_id>/vote/", views.vote, name='vote'),
]

# urlpatterns += staticfiles_urlpatterns()
